package com.ysh.controller;


import com.ysh.domain.Item;
import com.ysh.domain.Order;
import com.ysh.service.ItemService;
import com.ysh.service.UserService;
import com.ysh.service.impl.ItemServiceImpl;
import com.ysh.service.impl.UserServiceImpl;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class ItemsController {
    ItemService itemService = new ItemServiceImpl();


    // 3.添加商品信息
    @Test
    public void insertItem(){
        Item item = new Item("i004","香蕉",3.98,"海南");
        int result =itemService.addItem(item);
        if (result != 0){
            System.out.println("添加商品，成功！");
        } else{
            System.out.println("添加商品，失败！");
        }
    }
    // 6.查询商品信息
    @Test
    public void findItems(){
        // 集合对象存储User对象
        List<Item> list = new ArrayList<>();
        // 调用业务层，得到查询结果的list集合
        list = itemService.findItems();
        // 遍历输出
        for (Item item : list) {
            System.out.println(item);
        }
    }
}
